import {
    list,
} from '../../../../api/article';
const util = require('../../../../utils/util.js')
const app = getApp()
Component({
    properties: {

    },
    lifetimes: {
        created(){
            this.initQuestion()
        },
        attached(){}
    },
    data: {
        notice:[],
        tagIds: '',
        pageNum: 1,
        pageSize: 5,
        articleView:{},
        phoneHeight:""
    },
    methods: {
        toArticleDet(e){
            let id = e.currentTarget.dataset.item.id
            wx.navigateTo({
                url: `/pages/index/components/article/articleDet?id=${id}`,
            })
        },
        initQuestion () {
            let params={
                articleType:0,
                mchId: app.globalData.mchId,
                sortField:"id",
                sortType:'desc',
                pageNum: this.data.pageNum,
                pageSize: this.data.pageSize,
            }
            list(params).then(res => {
                if (this.data.pageNum==1) {
                    this.data.notice = []
                }
                if (res.data.data.length>0) {
                    res.data.data.forEach(item=>{
                        this.data.notice.push(item)

                    })
                }
                this.setData({
                    notice:this.data.notice
                })
            })
        },
    }
});
